<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "user_department".
 *
 * @property int $id id
 * @property int $user_id 用户id
 * @property string $department_number 部门编号
 * @property string $created_by 创建者
 * @property string $created_at 创建时间
 * @property string $updated_by 最后修改者
 * @property string $updated_at 最后修改时间
 */
class UserDepartment extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user_department';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['department_number'], 'string', 'max' => 255],
            [['created_by', 'updated_by'], 'string', 'max' => 45],
            [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'user_id' => Yii::t('app', 'User ID'),
            'department_number' => Yii::t('app', 'Department Number'),
            'created_by' => Yii::t('app', 'Created By'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_by' => Yii::t('app', 'Updated By'),
            'updated_at' => Yii::t('app', 'Updated At'),
        ];
    }
}
